hvm: hpet: Fix overflow when converting to nanoseconds.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Jan 2008 16:20:04 +0000 (16:20 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 8 Jan 2008 16:20:04 +0000 (16:20 +0000)
commit73ee2f2e11fcdc27aae4f8caa72d240c4c9ed5ac
tree8be74b360d3f5911344a42da2fef88e34126ae3b
parent10e3974b14613c687ce84decc019f4e016063caa
hvm: hpet: Fix overflow when converting to nanoseconds.

Currently in hpet_tick_to_ns, the approach is multiplying first, which
easily causes overflow when tick is quite large. The patch cannot
handle arbitratry large ticks duo to the precision requirement and
64bit's value range. But by optimize the equation, a larger ticks than
current code can be supported. Also an overflow check is added before
the calculation.

From: Haitao Shan <haitao.shan@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/hvm/hpet.c
xen/include/asm-x86/hvm/vpt.h